package com.zhonglz.designPattern.observer;

import javax.annotation.security.PermitAll;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.zhonglz.designPattern.observer.event.ModelEvent;
import com.zhonglz.designPattern.observer.model.TestInfoA;

/***
 * 设计模式---观察者模式
 * 注意：学习中简单demo
 * @author zhonglz
 */
@RestController
@RequestMapping("/test")
@PermitAll
public class TestDemo {
	
	@Autowired
	private EventBroadcaster eventBroadcaster;
	
	@ResponseBody
    @RequestMapping("guanchazhemoshi")
	public void guanchazhemoshi() {
		EventBroadcaster eventBroadcaster =new EventBroadcaster();
		TestInfoA info = new TestInfoA();
		info.setId(1L);
		info.setName("张三");
		eventBroadcaster.broadcastEvent(new ModelEvent(info));
	}
}
